import axios from 'axios'
const instance = axios.create({
  baseURL: '/api',
})

// 配置响应拦截器.让axios请求回来的数据,promise成功之后的value值就是响应主体的数据
instance.interceptors.response.use(function (response) {
  return response.data
})

// 配置请求拦截器,当axios发送之前,将token添加到header中
instance.interceptors.request.use(function (config) {
  config.headers = {
    authorization: localStorage.getItem('authorization'),
  }
  return config
})

export default instance
